<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>员工列表</title>
    <link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
    <script src="${pageContext.request.contextPath}/static/js/jquery-3.5.1.js"></script>
</head>
<body>
    <%--界面搭建--%>
     <div class="container">
    <%--标题--%>
         <div class="row">
             <div class="col-md-12">
                 <h1>SMM-CRUD</h1>
             </div>
         </div>
     </div>
    <%--按钮--%>
    <div class="row">
        <div class="col-md-4 col-md-offset-9">
            <button class="btn btn-primary">新增</button>
            <button class="btn btn-danger">删除</button>
        </div>
    </div>
    <!-- 显示表格数据 -->
    <div class="row">
        <div class="col-md-11 col-md-offset-1">
            <table class="table table-hover" >
                <tr>
                    <th>#</th>
                    <th>epmName</th>
                    <th>gender</th>
                    <th>email</th>
                    <th>deptName</th>
                    <th>操作</th>
                </tr>
                <c:forEach items="${pageInfo.list}" var="emp">
                    <tr>
                        <th class="active">${emp.empId}</th>
                        <th class="success">${emp.empName}</th>
                        <th class="warning">${emp.gender}</th>
                        <th class="danger">${emp.email}</th>
                        <th class="info">${emp.dept.deptName}</th>
                        <th>
                            <button class="btn-primary">
                                <span class="glyphicon glyphicon-pencil"></span>编辑
                            </button>
                            <button class="btn-danger">
                                <svg width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-trash" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
                                    <path d="M5.5 5.5A.5.5 0 0 1 6 6v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5zm2.5 0a.5.5 0 0 1 .5.5v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5zm3 .5a.5.5 0 0 0-1 0v6a.5.5 0 0 0 1 0V6z"/>
                                    <path fill-rule="evenodd" d="M14.5 3a1 1 0 0 1-1 1H13v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V4h-.5a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1H6a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1h3.5a1 1 0 0 1 1 1v1zM4.118 4L4 4.059V13a1 1 0 0 0 1 1h6a1 1 0 0 0 1-1V4.059L11.882 4H4.118zM2.5 3V2h11v1h-11z"/>
                                </svg>删除
                            </button>
                        </th>
                    </tr>
                </c:forEach>
            </table>
        </div>
    </div>
    <!-- 显示分页信息 -->
    <div class="row">
        <div class="col-md-4 col-md-offset-1" style="font-weight: bold">当前${pageInfo.pageNum}页,总${pageInfo.pages}页，总${pageInfo.total}条记录</div>
        <div class="col-md-4 col-md-offset-8">
            <nav aria-label="Page navigation">
            <ul class="pagination">
                <c:if test="${pageInfo.hasPreviousPage }">
                <li><a href="${pageContext.request.contextPath}/emps?pn=1">首页</a></li>
                    <li>
                        <a href="${pageContext.request.contextPath}/emps?pn=${pageInfo.pageNum-1}" aria-label="Previous">
                            <span aria-hidden="true">&laquo;</span>
                        </a>
                    </li>
                </c:if>

                <c:forEach items="${pageInfo.navigatepageNums}" var="page_Num">
                    <c:if test="${page_Num == pageInfo.pageNum}" >
                        <li class="active"><a href="#">${page_Num}</a></li>
                    </c:if>

                    <c:if test="${page_Num != pageInfo.pageNum}" >
                        <li ><a href="${pageContext.request.contextPath}/emps?pn=${page_Num}">${page_Num}</a></li>
                    </c:if>
                </c:forEach>




                <c:if test="${pageInfo.hasNextPage }">
                    <li>
                        <a href="${pageContext.request.contextPath}/emps?pn=${pageInfo.pageNum+1}" aria-label="Next">
                            <span aria-hidden="true">&raquo;</span>
                        </a>
                    </li>
                <li><a href="${pageContext.request.contextPath}/emps>pn=${pageInfo.pages}">末页</a></li>
                </c:if>
            </ul>
            </nav>
        </div>
    </div>
</body>
</html>
